package listbyorder.access301_400.test324;

import java.util.Arrays;

public class Solution1 {

    // 生成对应的数组
    public void wiggleSort(int[] nums) {
        int n = nums.length;
        if (n < 2) return;
        int[] temp = new int[n];
        for (int i = 0; i < n; i++) {
            temp[i] = nums[i];
        }
        Arrays.sort(temp);
        int r = n;
        int l = (n + 1) / 2;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                nums[i] = temp[l--];
            } else {
                nums[i] = temp[r--];
            }
        }
    }
}
